package com.acme.iolab.filesend;


import com.acme.iolab.filesend.io.IOFileClient;
import com.acme.iolab.filesend.nio.NIOFileClient;

import java.io.IOException;

public abstract class FileClient {

    private final static String FILE_PATH = "F:\\FileFolder\\data";
    protected final String serverIp;
    protected final int port;

    public FileClient(String serverIp, int port) {
        this.serverIp = serverIp;
        this.port = port;
    }

    public static void main(String[] args) throws IOException {
        String type = "-nio";
        FileClient client;
        switch (type) {
            case "-io":
                client = new IOFileClient(ConnectionSettings.IP, ConnectionSettings.PORT);
                break;
            case "-nio":
                client = new NIOFileClient(ConnectionSettings.IP, ConnectionSettings.PORT);
                break;
            default:
                System.out.println("Incorrect argument, required -io | -nio");
                return;
        }

        try {
            client.sendFile(FILE_PATH);
        } catch (IOException e) {
            System.out.println("Error sending file: " + e.getMessage());
            e.printStackTrace();
        }
    }

    public abstract void sendFile(String filePath) throws IOException;
}
